﻿@inject IStringLocalizer<FloatingLabels> Localizer

<div class="row g-3">
    <div class="col-12 col-sm-6 col-form-label align-self-center">@Localizer["FloatingLabelFormatterDiv2"] <code class="ms-1">FormatString</code></div>
    <div class="col-12 col-sm-6">
        <FloatingLabel DisplayText="FormatString" Value="DateTime.Now" FormatString="yyyy-MM-dd" IsDisabled="true" />
    </div>
    <div class="col-12 col-sm-6 col-form-label align-self-center">@Localizer["FloatingLabelFormatterDiv2"] <code class="ms-1">Formatter</code></div>
    <div class="col-12 col-sm-6">
        <FloatingLabel DisplayText="Formatter" Value="DateTime.Now" Formatter="@DateTimeFormatter" IsDisabled="true" />
    </div>
</div>
<p class="mt-3">@((MarkupString)Localizer["FloatingLabelFormatterDescription"].Value)</p>
<div class="row g-3">
    <div class="col-12 col-sm-6 col-form-label align-self-center">@Localizer["FloatingLabelFormatterDiv2"] <code class="ms-1">Formatter</code></div>
    <div class="col-12 col-sm-6">
        <FloatingLabel DisplayText="@Localizer["FloatingLabelFormatterDisplayText"]" Value="@ByteArray" Formatter="@ByteArrayFormatter" IsDisabled="true" />
    </div>
</div>

@code
{
    private byte[] ByteArray { get; set; } = new byte[] { 0x01, 0x12, 0x34, 0x56 };

    private static string ByteArrayFormatter(byte[] source) => Convert.ToBase64String(source);

    private static string DateTimeFormatter(DateTime source) => source.ToString("yyyy-MM-dd");
}
